﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using MovieRental.Entities;

namespace MovieRental.EnhancedEntities
{
    public abstract class BaseEnhancedEntity<TEntity> : INotifyPropertyChanged where TEntity : INotifyPropertyChanged
    {
        public TEntity Entity { private set; get; }

        public BaseEnhancedEntity(TEntity entity)
        {
            Entity = entity;
            Entity.PropertyChanged += new PropertyChangedEventHandler(EntityChanged);    
        }

        protected void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }

        protected virtual void EntityChanged(object sender, PropertyChangedEventArgs e)
        {
        }

        public event PropertyChangedEventHandler PropertyChanged;

        
    }
}
